import java.util.ArrayList;
import java.util.Collections;

public class Solution1 {
    public class ListNode {
    int val;
    ListNode next = null;
}
    /**
     * 
     * @param head ListNode类 the head
     * @return bool布尔型
     */
    public boolean isPail (ListNode head) {
        // write code here
        ArrayList<Integer>nums=new ArrayList<>();
        while(head!=null){
            nums.add(head.val);
            head=head.next;
        }
        ArrayList<Integer>temp=new ArrayList<>();
        temp=(ArrayList<Integer>)nums.clone();
        Collections.reverse(temp);
        for(int i=0;i<nums.size();i++){
            int x=nums.get(i);
            int y=temp.get(i);
            if(x!=y){
                return false;
            }

        }
        return true;
    }
}